using System;

namespace Terra.Service.Identity.DTOs;

/// <summary>
/// 登录请求DTO
/// </summary>
/// <remarks>
/// 用于用户登录的数据传输对象，支持以下登录方式：
/// <list type="bullet">
/// <item><description>用户名登录</description></item>
/// <item><description>邮箱登录</description></item>
/// <item><description>手机号登录</description></item>
/// </list>
/// </remarks>
public class LoginRequestDto
{
    /// <summary>
    /// 用户名/邮箱/手机号
    /// </summary>
    /// <example>admin@terra.com</example>
    public string Username { get; set; }

    /// <summary>
    /// 密码
    /// </summary>
    /// <example>Admin@123</example>
    public string Password { get; set; }
}

/// <summary>
/// 登录响应DTO
/// </summary>
/// <remarks>
/// 包含登录成功后的令牌信息和用户基本信息
/// </remarks>
public class LoginResponseDto
{
    /// <summary>
    /// 访问令牌，用于API接口认证
    /// </summary>
    /// <example>Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...</example>
    public string AccessToken { get; set; }

    /// <summary>
    /// 刷新令牌，用于获取新的访问令牌
    /// </summary>
    /// <example>8eYS8w37ByH4TKqJ...</example>
    public string RefreshToken { get; set; }

    /// <summary>
    /// 访问令牌的过期时间（UTC）
    /// </summary>
    /// <example>2024-03-16T10:30:00Z</example>
    public DateTime ExpiresAt { get; set; }

    /// <summary>
    /// 当前登录用户的基本信息
    /// </summary>
    public UserDto User { get; set; }
}

/// <summary>
/// 刷新令牌请求DTO
/// </summary>
/// <remarks>
/// 用于在访问令牌过期时，使用刷新令牌获取新的访问令牌
/// </remarks>
public class RefreshTokenRequestDto
{
    /// <summary>
    /// 过期的访问令牌
    /// </summary>
    /// <example>Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...</example>
    public string AccessToken { get; set; }

    /// <summary>
    /// 有效的刷新令牌
    /// </summary>
    /// <example>8eYS8w37ByH4TKqJ...</example>
    public string RefreshToken { get; set; }
}

/// <summary>
/// 令牌响应DTO
/// </summary>
/// <remarks>
/// 包含新生成的访问令牌和刷新令牌信息
/// </remarks>
public class TokenResponseDto
{
    /// <summary>
    /// 新的访问令牌（不包含Bearer前缀）
    /// </summary>
    public string Data { get; set; }

    /// <summary>
    /// 状态码
    /// </summary>
    public int Status { get; set; } = 200;

    /// <summary>
    /// 刷新令牌（用于存储）
    /// </summary>
    public string RefreshToken { get; set; }
}

/// <summary>
/// 修改密码请求DTO
/// </summary>
/// <remarks>
/// 用于用户修改密码操作，需要同时提供当前密码和新密码
/// </remarks>
public class ChangePasswordRequestDto
{
    /// <summary>
    /// 当前密码
    /// </summary>
    /// <example>OldPassword@123</example>
    public string CurrentPassword { get; set; }

    /// <summary>
    /// 新密码（必须符合密码策略要求）
    /// </summary>
    /// <example>NewPassword@123</example>
    public string NewPassword { get; set; }
}